﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using devtm.Configuration.Validators;
using devtm.Config;

namespace devtm.Configuration.Models
{


    [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
    public class CustomDesignerAttribute : ConfigurationValidatorAttribute
    {


        public CustomDesignerAttribute(String type)
        {
            this.TypeDesigner = type;
        }


        /// <summary>
        /// Gets or sets the type of the custom designer editor.
        /// </summary>
        /// <value>The type.</value>
        public String TypeDesigner { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the property is readonly for override the <c>true</c> value in <c>false</c> value
        /// </summary>
        /// <value><c>true</c> if [read only]; otherwise, <c>false</c>.</value>
        public bool ReadOnly { get; set; }

        public string PathName { get; set; }


        public override ConfigurationValidatorBase ValidatorInstance
        {
            get
            {
                

                switch (TypeDesigner)
                {
                    case ConfigConstants.Design.ConnexionStringNameParam:
                        return new ConnectionStringNameValidator();

                    case ConfigConstants.Design.TypeDesignerParam:
                    case ConfigConstants.Design.IgnoreParam:
                    case ConfigConstants.Design.IPHostDesignerParam:
                    case ConfigConstants.Design.RequireConfigurationSectionParam:
                    case ConfigConstants.Design.ListOfDesignerParam:
                    case ConfigConstants.Design.UriParam:
                    case ConfigConstants.Design.VersionParam:
                    case ConfigConstants.Design.ListeSelectorParam:
                        return new MockValidator();

                    default:
                        return new MockValidator();
                        
                }

            }
        }
        
    }
}
